#include "libconfig.h"
#include "InCommon.h"
#include "InSdkDevInfo.h"
#include "InComStringHandling.h"
#include "InSdkSetDevInfo.h"

#define DEF_TAG             "SetInfo"

#define DEF_PARAM_ALL           "-a"
#define DEF_PARAM_PID           "-p"
#define DEF_PARAM_UID           "-u"
#define DEF_PARAM_AUTHKEY       "-k"

Com_void InSdk_SetDevInfo_Usage(Com_ps8 tool)
{
    PRT_NORMAL("usage:\n");
    PRT_NORMAL("%s %s uid authkey\n", tool, DEF_PARAM_ALL);
    PRT_NORMAL("%s %s pid\n", tool, DEF_PARAM_PID);
    PRT_NORMAL("%s %s uid\n", tool, DEF_PARAM_UID);
    PRT_NORMAL("%s %s authkey\n", tool, DEF_PARAM_AUTHKEY);
}

int main(int argc, char *argv[])
{
    if (argc < 3)
    {
        InSdk_SetDevInfo_Usage(argv[0]);
        return -1;
    }
    else if (argc < 4)
    {
        if (strcmp(DEF_PARAM_UID, argv[1]) == 0)
        {
            Ext_InSdkSetInfo_UUID(argv[2]);
        }
        else if (strcmp(DEF_PARAM_AUTHKEY, argv[1]) == 0)
        {
            Ext_InSdkSetInfo_Authkey(argv[2]);
        }
        else if (strcmp(DEF_PARAM_PID, argv[1]) == 0)
        {
            Ext_InSdkSetInfo_Pid(argv[2]);
        }
    }
    else if (argc < 5)
    {
        if (strcmp(DEF_PARAM_ALL, argv[1]) == 0)
        {
            Ext_InSdkSetInfo_UUID(argv[2]);
            Ext_InSdkSetInfo_Authkey(argv[3]);
        }
    }
    else
    {
        PRT_WARN(DEF_TAG, "param too much\n");
        InSdk_SetDevInfo_Usage(argv[0]);
    }

    return 0;
}
